/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package calculation;

import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author jzajaczek
 */
@ManagedBean(name="TensionBean")
@SessionScoped
public class TensionBean implements Serializable {
    @ManagedProperty(value="100000.0")
    private double load; //[N]
    private double tension;
    
    private String check() {
        return "true";
    };
    
    private ToolUnitBean tu = new ToolUnitBean();
   
    private AreaBean a() {
        HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
            return (AreaBean) request.getSession().getAttribute("ring_area");
    }

    /**
     * @return the Load
     */
    public double getLoad() {
        return load;
    }

    /**
     * @param f the Load to set
     */
    public void setLoad(double load) {
        this.load = load;
    }

    /**
     * @return the tension
     */
    public double getTension() {
        return tu.round(load / a().getArea(), 2);
    }

    /**
     * @param tension the tension to set
     */
    public void setTension(double tension) {
        this.tension = tension;
    }
}